package com.wk.springbootlearn.common.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.io.File;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String property = System.getProperty("user.dir");
        File file = new File(property);
        String filePath = file.getPath() + File.separator + "public" + File.separator;
        registry.addResourceHandler("/file/**").addResourceLocations("file:"+filePath);
    }

}
